import os
import time


# 调用大模型总结每个簇的功能特征标签
def run_summary(args):
    promt_file, output_path, multi = args
    cmd = (
        "python ./gene_cluster_glm_4_summary_multipro.py -input " + promt_file +
        " -output " + output_path + " -multi " + multi
    )
    os.system(cmd)
 
if __name__ == '__main__':
    start_time = time.time()
    # 生成任务数量
    files = os.listdir("./04.prompt")
    exists_files = os.listdir("/home/pengkesheng/PGC/gene_cluster/05.gene_cluster_glm_summary_1")
    exists_files_name = dict.fromkeys([x.split(".")[0] for x in exists_files])
    file_path = [os.path.join("./04.prompt", x) for x in files if x.split(".")[0] not in exists_files_name]
    output_path = [os.path.join("./05.gene_cluster_glm_summary", x.split(".")[0] + ".xlsx") for x in files]
    os.makedirs("./05.gene_cluster_glm_summary", exist_ok=True)
    multi_list = ["50"] * len(file_path)
    
    task_list = list(zip(file_path, output_path, multi_list))
    print("\n\n\n执行的任务上数量是：\n\t", len(task_list), "\n")
    
    for task in task_list:
        print("\n\n" + task, "已经运行完成!\n\n")
        run_summary(task)
    
    end_time = time.time()
    total_time = end_time - start_time
    print(f"\n任务数量是 {len(task_list)} :\n", f"\t用时 {total_time}s\n")
